home *** CD-ROM | disk | FTP | other *** search
/ Network Support Library / RoseWare - Network Support Library.iso / apidev / sc3x03.exe / OBFSDINF.C < prev    next >
C/C++ Source or Header  |  1993-04-19  |  5KB  |  118 lines

  1. //   ╔════════════════════════════════════════════════════════════════════╗
  2. //   ║                                                                    ║
  3. //   ║ module:      OBFSDINF.C                                            ║
  4. //   ║ abstract:    This module shows how to make 3.x system calls using  ║
  5. //   ║              the F2 Shell Interface for the Obtain File or         ║
  6. //   ║              Subdirectory Information API, obviously it requires   ║
  7. //   ║              the NetWare Shell.                                    ║
  8. //   ║                                                                    ║
  9. //   ║ environment: NetWare 3.x v3.11                                     ║
  10. //   ║              Borland C++ 3.1                                       ║
  11. //   ║                                                                    ║
  12. //   ║  This software is provided as is and carries no warranty           ║
  13. //   ║  whatsoever.  Novell disclaims and excludes any and all implied    ║
  14. //   ║  warranties of merchantability, title and fitness for a particular ║
  15. //   ║  purpose.  Novell does not warrant that the software will satisfy  ║
  16. //   ║  your requirements or that the software is without defect or error ║
  17. //   ║  or that operation of the software will be uninterrupted.  You are ║
  18. //   ║  using the software at your risk.  The software is not a product   ║
  19. //   ║  of Novell, Inc. or any of subsidiaries.                           ║
  20. //   ║                                                                    ║
  21. //   ╚════════════════════════════════════════════════════════════════════╝
  22. //
  23. //                         ****** N O T I C E ******
  24. //
  25. //     This software is considered pre-release and may be used at your own
  26. //     risk and has been provided due to the many requests of our cust-
  27. //     omers.  Support for this module will be provided at the sole
  28. //     discretion of Novell, Inc.
  29. //
  30.  
  31. #include <stdio.h>
  32. #include <string.h>
  33.  
  34. #include "nwsys.h"
  35.  
  36. struct OB_REQUEST {
  37.     BYTE  sfCode;           // subfunction code
  38.     BYTE  nameSpace;
  39.     BYTE  destNameSpace;    // destination name space
  40.     WORD  searchAttributes;
  41.     DWORD returnInfoMask;   // return information mask
  42.     BYTE  volumeNumber;
  43.     DWORD dirHandle;        // directory base or short directory handle
  44.     BYTE  handleFlag;
  45.     BYTE  pathCompCount;    // path component count
  46.     BYTE  buffer[512];
  47. } obtainRequest;
  48.  
  49. struct OB_REPLY {
  50.     BYTE  reserved1[4];
  51.     BYTE  reserved2[6];
  52.     BYTE  reserved3[4];
  53.     BYTE  reserved4[6];
  54.     BYTE  reserved5[8];
  55.     BYTE  reserved6[10];
  56.     BYTE  reserved7[8];
  57.     BYTE  reserved8[2];
  58.     BYTE  reserved9[12];
  59.     BYTE  reserved10[12];
  60.     DWORD creatorNameSpaceNumber;
  61.     BYTE  reserved[257];
  62. } obtainReply;
  63.  
  64. int main()
  65. {
  66.     int i, retCode;
  67.     char volName[80], dirName[80], subDirName[80], fileName[80];
  68.     BYTE *bufptr;
  69.  
  70.     obtainRequest.sfCode = 0x06;
  71.     obtainRequest.nameSpace = 0;
  72.     obtainRequest.destNameSpace = 0;
  73.     obtainRequest.searchAttributes = 0xff;
  74.     obtainRequest.returnInfoMask = 0x0200;
  75.     obtainRequest.volumeNumber = 0;
  76.     obtainRequest.dirHandle = 0xff;
  77.     obtainRequest.handleFlag = 0xff;
  78.  
  79.     /* A qualified NetWare path must be passed to the function.  Every
  80.        element of the path is included separately in the buffer,
  81.        length-preceded.  This example uses SYS:MPINSONN\TEST\CONFIG.SYS.
  82.        The pathCompCount parameter must equal the number of path
  83.        components, in this case 4. */
  84.  
  85.     strcpy(volName,    "SYS");
  86.     strcpy(dirName,    "MPINSONN");
  87.     strcpy(subDirName, "TEST");
  88.     strcpy(fileName,   "CONFIG.SYS");
  89.  
  90.     obtainRequest.pathCompCount = 4;
  91.     bufptr = obtainRequest.buffer;
  92.  
  93.     *bufptr = strlen(volName);
  94.     strcpy(++bufptr, volName);
  95.     bufptr += strlen(volName);
  96.  
  97.     *bufptr = strlen(dirName);
  98.     strcpy(++bufptr, dirName);
  99.     bufptr += strlen(dirName);
  100.  
  101.     *bufptr = strlen(subDirName);
  102.     strcpy(++bufptr, subDirName);
  103.     bufptr += strlen(subDirName);
  104.  
  105.     *bufptr = strlen(fileName);
  106.     strcpy(++bufptr, fileName);
  107.  
  108.     retCode = NWSystemCall(0x57, &obtainRequest, sizeof(struct OB_REQUEST),
  109.                                  &obtainReply,   sizeof(struct OB_REPLY));
  110.     if (retCode == 0) 
  111.         printf("Creator name space number: %d\n", 
  112.             obtainReply.creatorNameSpaceNumber);
  113.     else
  114.         printf("Obtain File or SubDirectory Information failed.  Return code = 0x%x\n",
  115.             retCode);
  116.     return(0);
  117. }
  118.